/*
Test_CodeBlueNotification_Controller
Version 1.0
Description: Test class for CodeBlueCaseNotification_Controller class.
Author: Praibh Prakash
Created Date: 24 Feb-2009
*/
@isTest
private class Test_CodeBlueNotification_Controller {
    static testMethod void test_CodeBlueNotification(){
        
        //Creating Account and Contact records for relating to new Case record.
        Account account = new Account(Name='Test',Code_Blue_Account_Notification_List__c='Test1@Test1.com', Code_Blue_Regional_Notification_List__c='Test2@Test2.com');
        insert account;
        Contact contact = new Contact(LastName='Test', AccountId = account.Id);
        insert(contact);
        
        /*
        Case 1: Generates exception in constructor.
        */
        Case tempCase = new Case( ContactId= contact.Id, AccountId = account.Id, Code_Blue_Active__c = false, Status = 'Working');
        insert(tempCase);
        ApexPages.StandardController sc = new ApexPages.StandardController(tempCase);
        delete(tempCase);
        CodeBlueCaseNotification_Controller codeBlue = new CodeBlueCaseNotification_Controller(sc);
        
        /*
        Case 2: When Code_Blue_Active__c = false for a Case record and
                no task record is related to it.
        */
        //Creating Case record and relating to Account, Contact.
        Case objCase = new Case( ContactId= contact.Id, AccountId = account.Id, Code_Blue_Active__c = false, Status = 'Working');
        insert(objCase);
        ApexPages.StandardController sc1 = new ApexPages.StandardController(objCase);
        CodeBlueCaseNotification_Controller codeBlue1 = new CodeBlueCaseNotification_Controller(sc1);
        codeBlue1.pageForward();
        
        /*
        Case 3: When Code_Blue_Active__c = true && Status = 'Closed' for a Case record and
                no task record is related to it.
        */
        objCase.Code_Blue_Active__c = true;
        objCase.Status = 'Closed';
        update(objCase);
        ApexPages.StandardController sc2 = new ApexPages.StandardController(objCase);
        CodeBlueCaseNotification_Controller codeBlue2 = new CodeBlueCaseNotification_Controller(sc2);   
        
        
        /*
        Case 4: When Code_Blue_Active__c = true and Status != 'Closed' for a Case record and
                a task record is related to it.
        */
        objCase.Status = 'Working';
        update(objCase);
        Task task = new Task(Description = account.Code_Blue_Account_Notification_List__c+';'+account.Code_Blue_Regional_Notification_List__c+'CC', WhatId = objCase.Id, Type__c = 'Code Blue Notification',Subject = 'xxxxCode Blue NotificationxxxxxCC');
        insert(task);
        ApexPages.StandardController sc3 = new ApexPages.StandardController(objCase);
        CodeBlueCaseNotification_Controller codeBlue3 = new CodeBlueCaseNotification_Controller(sc3);
        
        /*
        Case 5: When Code_Blue_Active__c = true and Status = 'Closed' for a Case record and
                a task record is related to it.
        */
        objCase.Status = 'Closed';
        update(objCase);
        ApexPages.StandardController sc4 = new ApexPages.StandardController(objCase);
        CodeBlueCaseNotification_Controller codeBlue4 = new CodeBlueCaseNotification_Controller(sc4);
        codeBlue4.pageForward();
        
        /*
        Case 6: When Case Record Id has to be retreived from URL and there is a Task record related to that case.
        */
        Case objCloseCase1 = new Case( ContactId= contact.Id, AccountId = account.Id, Code_Blue_Active__c = true, Status = 'Working');
        PageReference closePage1 = new PageReference('/apex/CodeBlueCaseNotification?caseid='+objCase.Id );
        System.currentPageReference().getParameters().put('caseid', objCase.Id );
        //Test.setCurrentPage(closePage1);
        ApexPages.StandardController sc5 = new ApexPages.StandardController(objCloseCase1);
        CodeBlueCaseNotification_Controller codeBlue5 = new CodeBlueCaseNotification_Controller(sc5);
        codeBlue5.pageForward();
        
        /*
        Case 7: When Case Record Id has to be retreived from URL and there no Task record related to that case.
        */
        Case objCloseCase2 = new Case( ContactId= contact.Id, AccountId = account.Id, Code_Blue_Active__c = true, Status = 'Working');
        insert(objCloseCase1);
        PageReference closePage2 = new PageReference('/apex/CodeBlueCaseNotification?caseid='+objCloseCase1.Id );
        System.currentPageReference().getParameters().put('caseid', objCloseCase1.Id );
        //Test.setCurrentPage(closePage2);
        ApexPages.StandardController sc6 = new ApexPages.StandardController(objCloseCase2);
        CodeBlueCaseNotification_Controller codeBlue6 = new CodeBlueCaseNotification_Controller(sc6);
        codeBlue6.pageForward();
                
    }
}